<template>
    <view class="page">
        <view class="top-box">
            <uni-nav-bar leftIcon="left" :title="mDetails.name || '详情'" statusBar :border="false"
                backgroundColor="#FFFFFF" @clickLeft="handleBack"></uni-nav-bar>
        </view>
        <view class="richText">
            <u-parse :content="htmlContent"></u-parse>
        </view>
    </view>
</template>

<script setup>



import {
    ref
} from 'vue'

import {
    onLoad
} from '@dcloudio/uni-app'

import {
    getSinglePageData
} from '@/api/index.js'
const htmlContent = ref()
const mDetails = ref({})
const name = ref()


onLoad((options) => {
    if (options.name) {
        name.value = options.name
        getData()
    }
})


const getData = async () => {
    let res = await getSinglePageData({ name: name.value })
    if (res?.code) {
        console.log(res.data);
        mDetails.value = res.data || {}
        if (mDetails.value) {
            htmlContent.value = mDetails.value.content
        }
    }
}

const handleBack = () => {
    uni.navigateBack()
}
</script>
<style lang="scss" scoped>
.top-box {
    position: sticky;
    top: 0;
}

.page {
    background: white;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.richText {
    width: 710rpx;
    display: flex;
    flex-direction: column;
    margin: 0 20rpx 20rpx;
}
</style>